<template>
  <div>
    <el-dialog title="物流信息" :visible.sync="open" width="70%" :before-close="cancel">
      <div v-if="type=='2'">
        <el-table v-loading="loading" :data="queryList" border stripe>
          <!--          <el-table-column label="单号" prop="number" align="center" width="150"/>-->
          <el-table-column label="时间" prop="number" align="center" width="200">
            <template slot-scope="scope">
              {{
                scope.row.shipment.latest_event ? parseTime(scope.row.shipment.latest_event.time_iso) : '异常'
              }}
            </template>
          </el-table-column>
          <!--          <el-table-column label="地址" prop="number" align="center" width="200">-->
          <!--            <template slot-scope="scope">-->
          <!--              {{ scope.row.shipment.latest_event.location }}-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column label="描述" prop="name">
            <template slot-scope="scope">
              {{ scope.row.shipment.latest_event ? scope.row.shipment.latest_event.description : '异常' }}
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div v-else>
        <el-table v-loading="loading" :data="queryList" border stripe>
          <!--          <el-table-column label="单号" prop="mailNo" align="center" width="150"/>-->
          <el-table-column label="时间" prop="timeStr" align="center" width="200"/>
          <el-table-column label="描述" prop="desc"></el-table-column>
        </el-table>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {queryLogisticsInfo} from "@/api/autoOperation/python";

export default {
  name: "notStockLogisticsInfo",
  props: {
    trackingNo: {
      type: String / Number,
      default: ""
    }
  },
  data() {
    return {
      open: true,
      loading: true,
      queryList: [],
      type: "",// 1:菜鸟物流，2：非菜鸟
    }
  },
  created() {
    this.getLogisticsIngo()
  },
  methods: {
    getLogisticsIngo() {
      // let  id = '78757066760051'
      // let id = 'EV038622574CN'
      queryLogisticsInfo(this.trackingNo).then(res => {
        this.loading = false
        console.log('res', res)
        let type = res.type
        this.type = type
        if (type == '1') {
          this.queryList = res.data.module[0].detailList
        } else {
          this.queryList = res.data.shipments
        }
      })
    },
    cancel() {
      this.$emit('close')
    },
  }
}
</script>

<style scoped>

</style>
